package com.learn.lb.spark.sql


import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}

/**
 * spark1.x 操作方式，SQLContext
 *
 * @author laibo
 * @since 2019/8/9 16:16
 */
object SqlContextDemo {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("SqlContextDemo").setMaster("local[2]")
    val sc = new SparkContext(conf)
    val context = new SQLContext(sc)
    val stuDF = context.read.json("E:\\idea\\workspace\\bd-learn\\spark-learn\\src\\main\\resources\\student.json")
    stuDF.show()
    stuDF.createOrReplaceTempView("t_student")
    context.sql("select * from t_student")
  }
}
